import java.util.Scanner;

public class Main {

    public static char swap(int num)
    {
        switch(num){
            case 10:return 'a';
            case 11:return 'b';
            case 12:return 'c';
            case 13:return 'd';
            case 14:return 'e';
            case 15:return 'f';
        }
        return (char)num;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //输入的十进制数
        int str = in.nextInt();
        //需要转换的进制数
        int str2 = in.nextInt();
        StringBuffer str3 = new StringBuffer();
        int num=0;
        if (str2 < 10) {
            //当十进制数大于需要装换的进制数时
            while (str2 <= str) {
                //字符串添加余数
                str3 .append(str % str2);
                str = str / str2;
            }
            //将剩余的余数添加到字符串
                str3 .append(str) ;
            System.out.printf(str3.reverse().toString());
        } else {
            while (str2 <= str) {
                num=str % str2;
                if(num>=10)
                {
                    str3 .append(swap(num));
                }
                else str3 .append(num);
                str = str / str2;
            }
            num=str % str2;
            if(num>=10)
            {
                str3 .append(swap(num));
            }
            else str3 .append(num);
            System.out.printf(str3.reverse().toString());
        }

    }
}